export default {
	getUserInfo(e,_this){
		console.log("getUserInfo")
		return  new Promise((resolve, reject) =>  {
			
			let {
				errMsg
			} = e.detail
			if (errMsg === 'getUserInfo:ok') {
				// 所有登陆，传入获取的json
				_this.$store.dispatch('loginByAllMin', e.detail).then(res => {
					resolve(res)
				}).catch(res=>{
					reject({errMsg:res,detail:e.detail})
				})
			}else{
				
				reject({errMsg:errMsg,detail:e.detail})
			}
		});
	},
	getUserInfoWithoutButton(_this){
		console.log("getUserInfoWithoutButton")
		return  new Promise((resolve, reject) =>  {
			uni.getUserInfo({
				withCredentials:true,
				success: (res) => {
					this.getUserInfo({detail:res},_this).then(res=>{
						resolve(res)
					}).catch(res=>{
						reject(res)
					});
				}
			})
		})
	},
	getUserProfile(_this){
		console.log("getUserProfile")
		return  new Promise((resolve, reject) =>  {
			uni.getUserProfile({
				desc: '用于完善会员资料', 
				success: (res) => {
					if(res.errMsg=="getUserProfile:ok"){
						res.errMsg="getUserInfo:ok";
						this.getUserInfo({detail:res},_this).then(res=>{
							resolve(res)
						}).catch(res=>{
							reject(res)
						});
					}
				}
			})
		});
	}
	
}